<?php
error_reporting(0); 
$isadmin=1; 
include '../comm/config.php';
include '../comm/checkpostandget.php';
include 'check.php';
$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
	die(ERR_DB);
}
else
{
	mysql_query("set names utf8");	
	$tj="adminname='".$adminusername."'";
	$sql="select * from ".$BIAOTOU."duoduo2010 where ".$tj."";
	mysql_select_db($dbname);
	$rs = mysql_query($sql);
	while ($row = mysql_fetch_array($rs)){
		$loginnum=$row['loginnum'];
		$lastlogintime=$row['lastlogintime'];
		$lastloginip=$row['lastloginip'];
	}
	$sql="select * from ".$BIAOTOU."duoduo2010";
	$rs2 = mysql_query($sql);

}	
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<script language="javascript" type="text/javascript">	
function getLength(str) {
    var len = str.length;
    var reLen = 0;
    for (var i = 0; i < len; i++) {        
        if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
            // 全角    
            reLen += 2;
        } else {
            reLen++;
        }
    }
    return reLen;    
} 

function checkpass(password)
{
    	if(getLength(password)<6 || getLength(password)>20)
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
		}
		else
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码填写正确</font>';
		}
}    

function checkpass2()
{
    	if(getLength(document.getElementById("newpassword2").value)<6 || getLength(document.getElementById("newpassword2").value)>20)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			return false;
		}
		else if (document.getElementById("newpassword").value!=document.getElementById("newpassword2").value)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>两次密码输入不一致！</font>';
			return false;
		}
		else
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码再次确认正确</font>';
			return true;
		}
}    
function checkall()
{
	if(document.getElementById("username").value==""||document.getElementById("oldpassword").value==""||document.getElementById("newpassword").value==""||document.getElementById("newpassword2").value==""||!checkpass2())
	{
		return false;
	}
	else
	{
		return true;
	}
}
</script>
<style type="text/css">
<!--
.STYLE1 {
	color: #FFFFFF;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
.STYLE2 {
	color: #555555;
	font-weight: bold;
	font-size:14px;
	text-decoration:none;
}
-->
</style>
</head>

<body topmargin="5" leftmargin="0">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="282" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
          <table cellspacing="0" width="100%" height="207" style="border:1px  solid #DCEAF7;">
            <tr>
              <td height="30" colspan="2" bgcolor="E9F2FB" class="bigtext"><strong>&nbsp;<img src="images/arrow.gif" width="16" height="22" align="absmiddle" /> 修改管理员信息</strong></td>
            </tr>
            <tr>
              <td width="100%" colspan="2" valign="top"><table width="100%" height="300" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><form id="form1" name="form1" method="post" action="savechgadmin.php" onsubmit="return checkall()">
<br />
<table width="720"  align="center" border=1 cellpadding=0 cellspacing=0 style="border-collapse: collapse" bordercolor="#dddddd">
                      <tr>
                        <td width="174" height="30" align="right" class="bigtext">管理员帐号：</td>
                        <td width="540" height="30" class="bigtext">&nbsp;<input name="username" type="text" class="btn3" value="<?=$adminusername?>" size="20" maxlength="20" />
                          （可修改）</td>
                      </tr>
					   <tr>
                        <td height="30" align="right" class="bigtext">原密码：</td>
                        <td height="30">&nbsp;<input name="oldpassword" type="password" class="btn3" id="oldpassword" size="22" maxlength="20" /></td>
                      </tr>
					   <tr>
                        <td height="30" align="right" class="bigtext">新密码：</td>
                        <td height="30"><table width="455" height="30" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="190">&nbsp;<input name="newpassword" type="password" class="btn3" id="newpassword" onblur="checkpass(document.getElementById('newpassword').value);" size="22" maxlength="20" /></td>
    <td width="265" id="ckpass">&nbsp;</td>
  </tr>
</table></td>
                      </tr>
					  <tr>
                        <td height="30" align="right" class="bigtext">再次输入新密码：</td>
                        <td height="30"><table width="455" height="30" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="190">&nbsp;<input name="newpassword2" type="password" class="btn3" id="newpassword2" onblur="checkpass2();" size="22" maxlength="20" /></td>
    <td width="265" id="ckpass2">&nbsp;</td>
  </tr>
</table></td>
                      </tr>
					   <tr>
                        <td height="30" align="right" class="bigtext">登录次数：</td>
                        <td height="30" class="bigtext">&nbsp;<?=$loginnum?></td>
                      </tr>
					  <tr>
                        <td height="30" align="right" class="bigtext">上次登录时间：</td>
                        <td height="30" class="bigtext">&nbsp;<?=$lastlogintime?></td>
                      </tr>
					  <tr>
                        <td height="30" align="right" class="bigtext">上次登录IP：</td>
                        <td height="30" class="bigtext">&nbsp;<?=$lastloginip?></td>
                      </tr>
					  <tr>
                        <td height="30" align="right" class="bigtext">管理账号列表：</td>
                        <td height="30" class="bigtext">&nbsp;<?php 
						$i=0;
						while ($row2 = mysql_fetch_array($rs2)){
							if($i==0){
								echo $row2["adminname"];
							}else{
								echo " , ".$row2["adminname"];
							}
						$i++;
						}
						echo "&nbsp;&nbsp;&nbsp;&nbsp;( 共 ". $i." 名 )"?></td>
                      </tr>		 
					   <tr>
                        <td height="50" align="right" class="bigtext">&nbsp;</td>
                        <td height="50">&nbsp;<input type="submit" name="Submit" value=" 修改资料 " /></td>
                      </tr>
                    </table>
                                    <br />
                  </form>
                  </td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
      
    </table></td>
  </tr>
</table>
</body>
</html>
<?php mysql_close($link);?>
